home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / mail / YAMscripts.lha / MakeHotlist.rexx < prev    next >
OS/2 REXX Batch file  |  1997-06-24  |  5KB  |  144 lines

  1. /*                         MakeHotlist.rexx
  2.                            v1.2 - 03-Jun-97
  3.  
  4.    This script grabs URLs from messages in the current folder 
  5.    and creates a hotlist which it sends to a browser.  Currently 
  6.    supported browsers are AWeb, IBrowse and Voyager.
  7.  
  8.    *IMPORTANT* You need to change the variable browser to a correct
  9.    value or the script will not be able to run your browser.
  10.  
  11.    All adresses which end with a character in variable dup_chars will be
  12.    duplicated and displayed also without that character.
  13.  
  14.    This script requires rexxreqtools and reqtools libraries, if the
  15.    filerequester is used.
  16.  
  17.    Send bug reports, comments and spare bodyparts to knikulai@utu.fi
  18. */
  19. options results
  20.  
  21. /* CHANGE THE FOLLOWING LINE */
  22. browser='Work:IBrowse/IBrowse'        /* Start this program if no browser is running */
  23. hname='YAM:HotList.html'           /* Full path and name of hotlist */
  24. tags='rt_pubscrname=YAMSCREEN'  /* Change here the name of the screen YAM runs */
  25.  
  26. /* If you wish to select the name of the hotlist, uncomment next three lines*/
  27. /*
  28. call addlib('rexxreqtools.library',0,-30,0)
  29. hname=rtfilerequest('YAM:','HotList.html','Enter name of the hotlist',,'rtfi_flags=freqf_save' tags)
  30. if hname='' then exit
  31. */
  32.  
  33. dup_chars='.,!?"*%&)'   /* If one of these ends the URL, it will be duplicated */
  34. not_found='Sorry,no URLs were found in any of the read messages!'
  35. uc=0                    /* URL-counter */
  36.  
  37. call open(hotlist,hname,'W')
  38.  
  39. address 'YAM'
  40. 'Request "Do you want to search for URLs from" "_All messages|_This message|_Quit"'
  41. if result=0 then exit
  42. OnlyOne=(result=2)
  43.  
  44. writeln(hotlist,'<html><head><title>URLs from YAM</title></head>')
  45. 'GetFolderInfo Name'
  46. writeln(hotlist,'<body><center><h3>URLs from messages in folder' result'</h3></center>')
  47. writeln(hotlist,'<center>An URL is only displayed once, even if it appears in several messages.</center>')
  48. writeln(hotlist,'<hr><ul>')
  49.  
  50. 'GetFolderInfo Max'
  51. loppu=result-1
  52. alku=0
  53. 'GetMailInfo Act'
  54. act=result
  55.  
  56. if OnlyOne then do
  57.     alku=act
  58.     loppu=act
  59.     end
  60.  
  61. do viesti=alku to loppu
  62.     'SetMail' viesti
  63.     'GetMailInfo File'
  64.     fname=result
  65.     'GetMailInfo Subject'
  66.     sub=result
  67.     'GetMailInfo Status'
  68.        if open(msg,fname,'R') then do
  69.            do until eof(msg)
  70.              rivi=translate(readln(msg),' ','"')
  71.              rivi=rivi || '  '                /* Just making sure there is a space at the end */
  72.              do while (pos('GOPHER://',upper(rivi))>0 | pos('HTTP://',upper(rivi))>0 | pos('FTP://',upper(rivi))>0)
  73.                 /* There might be several URLs on one line */
  74.                 b=pos('HTTP://',upper(rivi))          /* beginning */
  75.                 if b=0 then b=pos('FTP://',upper(rivi))
  76.                 if b=0 then b=pos('GOPHER://',upper(rivi))
  77.                 e=pos(' ',rivi,b)                     /* space ends the URL */
  78.                 if e-pos('//',rivi,b)>2 then do       /* only save if URL has chars in it */
  79.                     call AddURL(substr(rivi,b,e-b))   /* save URL */
  80.                     do while pos(right(url.uc,1),dup_chars)>0
  81.                         /* Add another URL without the last character */
  82.                         spare=left(url.uc,length(url.uc)-1)
  83.                         call AddURL(spare)
  84.                         end /* do while pos */
  85.                 end /*if e-pos('//',rivi,b)>2*/
  86.                 rivi=right(rivi,length(rivi)-e)
  87.              end /* do while (pos('GOPHER://',upper(rivi))> */
  88.            end /* do until eof(msg) */
  89.          close(msg)
  90.       end /* if open(msg,fname,'R') then do */
  91.  
  92. end /* do viesti=0 to n-1 */
  93. writeln(hotlist,'</ul><hr><a href="mailto:knikulai@utu.fi">Send praise, bug reports and pictures of Scully to knikulai@utu.fi</a></body></html>')
  94. call close(hotlist)
  95.  
  96. if uc=0 then
  97.    'request "'||not_found||'" "_Ok"'
  98. else do
  99.    lst=show('P') || '  '
  100.    hlst='file:///'hname
  101.    no_browser=1
  102.    if pos('MINDWALKER',lst)>0 then do
  103.       address 'MINDWALKER' 'OpenURL' hlst
  104.       no_browser=0
  105.       end
  106.    if pos('VOYAGER',lst)>0 then do
  107.       address 'VOYAGER' 'OpenURL' hlst 
  108.       no_browser=0
  109.       end
  110.    if pos('IBROWSE',lst)>0 then do
  111.       address 'IBROWSE' 'GotoURL' hlst
  112.       no_browser=0
  113.       end
  114.    if pos('AWEB',lst)>0 then do
  115.         address value substr(lst,pos('AWEB.',lst),6)
  116.         'Open file://localhost/' || hname
  117.     no_browser=0
  118.         end
  119.    if no_browser then do
  120.        'Request "You do not have a browser running.  The *nhotlist has been saved toP[3]' hname'P[1]*nWhat should I do?" "_Run browser|_End script"'
  121.     if result=0 then exit
  122.        address command 'run <>nil:' browser hlst
  123.     end
  124.    else
  125.        'Request "The hotlist has been sent to your browser." "_Ok"'
  126. end /* else */
  127. 'SetMail' act
  128.  
  129. exit
  130.  
  131. AddURL:
  132.   parse arg u
  133.   do i=1 to uc
  134.       if url.i=u then return
  135.       end
  136.   uc=uc+1
  137.   url.uc=u
  138.   if sub~='' then do /* First write the subject of the message */
  139.         writeln(hotlist,'</ul><p><p><strong>'|| sub ||'</strong><ul>')
  140.         sub=''
  141.         end
  142.   writeln(hotlist,'<li><a href="'|| u ||'">'|| u ||'</a>')
  143. return
  144.